<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="Dao.*,JavaBean.*,java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link type="text/css"  href="../css/style.css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<% 
    request.setCharacterEncoding("UTF-8");
		String  userId=request.getParameter("UserId");
		String  username=request.getParameter("name");
		String  mark=request.getParameter("role");
		out.print(username);
		out.print(mark);
		UserDao  dao=new UserDao();
		UserBean bean=new UserBean();
		bean.setMark(request.getParameter("role"));
		bean.setUserId(Integer.parseInt(userId));
		bean.setUsername(request.getParameter("name"));
		int result=dao.update(bean); 
		if(result>0){
			 out.println("<script>alert('修改成功！！');</script>"); 
		     out.println("<script>window.location.href='UserList.jsp'</script>");
			
		}
		if(result==-1){
			 out.println("<script>alert('修改失败！！');</script>"); 
		     out.println("<script>window.location.href='UserList.jsp'</script>");
		}
		if(result==-2){
			 out.println("<script>alert('连接错误！！');</script>"); 
		     out.println("<script>window.location.href='UserList.jsp'</script>");
		}
		
	%>
	<%-- <script type="text/javascript">
		function update() {
			var usernames=document.getElementById("username").value;
			var marks=document.getElementById("mark").value;
			alert(usernames);
			UserDao  dao=new UserDao();
			UserBean bean=new UserBean();
			bean.setMark(marks);
			bean.setUserId(Integer.parseInt(userId));
			bean.setUsername(usernames);
			int result=dao.update(bean); 
			if(result>0){
				alert('修改成功！！');
			    window.location.href='UserList.jsp';
				
			}
			if(result==-1){
				alert('修改失败！！');
				window.location.herf='UserList.jsp';
			}
			if(result==-2){
				alert('连接错误！！');
				window.location.herf='UserList.jsp';
			}
			
		}
	</script>
</head>

<body style="margin: 0 auto;border: 0px;text-align: center; ">

	<div>
		<h3 >用户信息</h3>
	<div>
	<form action="UserList.jsp" method="post" onsubmit="return update()" >

 		 <div class="top1">用户名Id:<input type="text" name="userId" value=<%=userId %>   style="height: 25px; width: 250px"></div>
		<div class="top1">用户名:<input type="text" name="username"    style="height: 25px; width: 250px"></div>
		<div class="top1">备注:<textarea rows="3" name="mark" cols="5"   style="height: 25px; width: 250px;margin-left:12px"></textarea></div> 
	  
		<div>
			 <input type="submit" class="btn" name="btnRegist" value="修改">
		</div>
	</form>
	</div>
	</div> 
</body>--%>
</html>